Repository navigation
feat(api): serve PromQL label lookups from ClickHouse's Prometheus HTTP API - #3628
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: d4468c3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
PR Review
1 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 1 minor None could be anchored to changed lines; they are listed below. Findings outside the changed lines1 minor
Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. The diff is a focused, defensively-written backend change: label lookups route to ClickHouse's 🟡 P2 — recommended
🔵 P3 nitpicks (1)
Reviewers (13): correctness, security, adversarial, reliability, api-contract, performance, kieran-typescript, testing, maintainability, project-standards, previous-comments, agent-native, learnings-researcher. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
E2E Test Results✅ All tests passed • 465 passed • 1 skipped • 1247s
Tests ran across 4 shards in parallel. |
The merge-base changed after approval.
98823ff to
d4468c3
Compare
Summary
Label lookups (
/labels,/label/:name/values) for ClickHouse-backed PromQL sources now go through ClickHouse'sprometheus_api_v1handler, the same way/queryand/query_rangealready do. SQL againsttimeSeriesTags()stays as the fallback.clickhouse-http, the server is 26.9+ (when the label endpoints shipped), and the existing handler probe passes. Otherwise lookups use SQL, so a source querying over HTTP on 26.6–26.8 keeps label autocomplete.supportsPrometheusLabelsApi(26.9+) to common-utils. The probe cache now stores{ query, labels }per connection, so no extra probe request is made.handleLabelLookupproxies with the source'sdatabase/table,start/end/limit/match[], and the ClickHouse auth and attribution headers. The chosen path is recorded on the span ashyperdx.promql.label_backend.limitis capped atPROMETHEUS_MAX_RESULT_ROWS(100k), including when absent or 0. The handler returns all values in one row, somax_result_rowscan't bound it the way it bounds the SQL path.match[]error now names the HTTP handler on 26.9+ as the alternative to storing time ranges.UNKNOWN_FUNCTION/UNKNOWN_TABLE) instead of message text.isClickHouseError/getClickHouseErrorTypemove frommcp/tools/query/helpers.tstoutils/clickhouseErrors.tsto avoid a circular import.How to reproduce
Starting point:
yarn dev(ClickHouse 26.10). In the ClickHouse play editor, run one statement at a time:In Team Settings → Sources, add a PromQL source on "Local ClickHouse" for
default.hdx5420_v8with the backend on Auto.On the base branch:
/api/v1/prometheus/label/job/values?sourceId=<id>&match[]=up(logged in).SYSTEM FLUSH LOGS, then:interface = HTTP, query text containstimeSeriesTags(.On this branch:
{"status":"success","data":["api","worker"]}.interface = TCP, query text starts withSELECT arraySort(groupUniqArrayArray(, and there is notimeSeriesTags(row.timeSeriesTags(SQL again.How to test on Vercel preview
N/A — non-UI change.
References